import Vue from 'vue'
import Vuex from 'vuex'
import { getToken, setToken } from '@/utils/token'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: getToken(),
    user: {}
  },
  getters: {
    GET_USER (state) {
      return state
    }
  },
  mutations: {
    setToken () {
      setToken()
    },

    SET_USER (state, userObj) {
      state.user = userObj
    },
    // 设置头像
    SET_USERPHOTO (state, photo) {
      state.user.photo = photo
    },
    // 修改名字
    SET_USERNAME (state, name) {
      state.user.name = name
    }
  },
  actions: {
  },
  modules: {
  }
})
